
# Files
HEADERS = $(wildcard src/*.h)
SRC = $(wildcard src/*.c)
OBJ = ${SRC:.c=.o}

# Project data
name = avgdl
version = 1.0
OUT = ./${name}

# Compiler arguments
CC = gcc
CFLAGS = #-Wall -Wextra -pedantic

### Rules ###

# Executable (default)
${OUT}: ${OBJ}
	$(CC) $(CFLAGS) -o $@ $(OBJ)

tarball:
	@echo making tarball ${name}-${version}.tar.gz
	tar -czf $(name)-$(version).tar.gz LICENSE makefile \
		${SRC} ${HEADERS} examples/* target/*

clean:
	@echo cleaning ...
	@-rm -f ${OUT} $(OBJ)
	@-rm -f $(name)-$(version).tar.gz 
	@-rm -rf build/
	@echo done

.PHONY : tarball clean

# Re-compile when any header changes
${OBJ}: ${HEADERS}

# How to compile c files
.c.o:
	${CC} ${CFLAGS} -c -o ${<:.c=.o} $<
